package animalitem;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;

import dbc.JDBCUtils;

public class UserItem {
	private String name;
	private String password;
	private String email;

	public UserItem() {
	}

	public UserItem(String name, String password, String email) {
		this.name = name;
		this.password = password;
		this.email = email;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}
	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}
	// »ñÈ¡¹ÜÀíÔ±Êý¾Ý
	public boolean queryAllData(String name, String password) {
		Connection conn = null;
		Statement stmt = null;
		ResultSet rs = null;
		boolean flag = false;
		ArrayList<UserItem> list = new ArrayList<UserItem>();
		try {
			conn = JDBCUtils.getConnectionSQL();
			stmt = conn.createStatement();
			String sql = "select name,password from uers where name = 'lcy' and password = '123456'";
			rs = stmt.executeQuery(sql);
			while (rs.next()) {
				UserItem thisUser = new UserItem();
				thisUser.setName(rs.getString("name"));
				thisUser.setPassword(rs.getString("password"));
				list.add(thisUser);
				if (name.equals(thisUser.getName())
						&& password.equals(thisUser.getPassword())) {
					flag = true;
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			JDBCUtils.close(conn);
		}
		return flag;
	}
}